(function () {
    'use strict';

    angular
    .module('app')
    .factory('APIProductService', APIProductService);

    APIProductService.$inject = ['$http', '$q', '$timeout', 'CacheFactory', 'ENUM'];

    function APIProductService($http, $q, $timeout, CacheFactory, ENUM) {

        var service = new APIEndpoint( $http, $q, $timeout, CacheFactory, 'APIProductService' );

        service.list = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.accessoryList = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.get = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.like = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.unlike = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.likedList = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.validate = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.purchase = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };


        return service;

    }

})();
